<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据集市列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <input type="hidden" th:value="${dm.idDrawDm}" id="idDrawDm">
            <input type="hidden" th:value="${dm.flds}" id="oldFlds">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>过滤：</label>
                            <input type="text" name="idIndex"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table class="table table-bordered">
                <colgroup>
                    <col width="20%">
                    <col width="40%">
                    <col width="40%">
                </colgroup>
                <thead>
                <tr>
                    <th></th>
                    <th>编码</th>
                    <th>名称</th>
                </tr>
                </thead>
                <tbody id="fildLIst" >
                <tr th:each="item:${flds}">
                    <td><input type="checkbox"></td>
                    <td th:text="${item.idPubfld}"></td>
                    <td th:text="${item.naPubfld}"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "base/etl/dm";
    function submitHandler() {
        var checkData = $("#fildLIst").find("input:checked");
        if(checkData.length<1) {
            $.modal.alertError("至少需要选择一条数据");
            return ;
        }
        var data=[],tds;
        debugger;
        var oldFlds = $("#oldFlds").val();
        var idDrawDm=$("#idDrawDm").val(),flds="";
        if(oldFlds!=null && oldFlds!="") {
            flds = oldFlds+",";
        } else {
            flds = "ID_DIM_DAY_OCCUR,"
        }
        var fld;
        $.each(checkData,function (index,item) {
            tds = $(this).parent().siblings();
            fld = tds[0].innerHTML;
            if(!flds.includes(fld+",")) {
                flds+=fld+",";
            }
        });
        $.ajax({
            url: prefix+"/edit?idDrawDm="+idDrawDm+"&flds="+flds.substring(0,flds.length-1),
            type: 'POST',
            async: false,
            success: function (result) {
                $.modal.close();
            }
        });
        return data;
    }
</script>
</body>
</html>